#pragma once

//用于管理子进程需要执行的任务
#include <iostream>
#include <vector>
#include <ctime>

typedef void (*task_t)();


void PrintLog()
{
    std::cout << "打印日志的任务" << std::endl;
}
 
void Download()
{
    std::cout << "下载的任务" << std::endl;
}
 
void Upload()
{
    std::cout << "上传的任务" << std::endl;
}

class Taskmanager
{
public:
    Taskmanager()
    {
        srand(time(nullptr));
    }
    //注册任务
    void Register(task_t t)
    {
        _tasks.push_back(t);
    }
    int Code()
    {
        return rand()%_tasks.size();
    }
    void Excute(int code)
    {
        if (code >= 0 && code < _tasks.size())
        {
            _tasks[code]();
        }
    }


private:
    std::vector<task_t> _tasks;
};